From: kfraser@localhost.localdomain Date: Tue, 17 Oct 2006 18:04:46 +0000 (+0100) Subject: [SOLARIS] Provide non-gcc-specific defn. of RING_HAS_UNCONSUMED_REQUESTS. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15589^2~62 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=44ce1b4011da58408f0788c2cdd9d8db23835b05;p=xen.git [SOLARIS] Provide non-gcc-specific defn. of RING_HAS_UNCONSUMED_REQUESTS. From: Mark Johnson Signed-off-by: Keir Fraser --- diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h index 6b56dc3211..d427ba6679 100644 --- a/xen/include/public/io/ring.h +++ b/xen/include/public/io/ring.h @@ -152,7 +152,7 @@ typedef struct __name##_back_ring __name##_back_ring_t ((_r)->nr_ents) /* Number of free requests (for use on front side only). */ -#define RING_FREE_REQUESTS(_r) \ +#define RING_FREE_REQUESTS(_r) \ (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons)) /* Test if there is an empty slot available on the front ring. @@ -165,13 +165,21 @@ typedef struct __name##_back_ring __name##_back_ring_t #define RING_HAS_UNCONSUMED_RESPONSES(_r) \ ((_r)->sring->rsp_prod - (_r)->rsp_cons) +#ifdef __GNUC__ +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ + unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ + unsigned int rsp = RING_SIZE(_r) - \ + ((_r)->req_cons - (_r)->rsp_prod_pvt); \ + req < rsp ? req : rsp; \ +}) +#else +/* Same as above, but without the nice GCC ({ ... }) syntax. */ #define RING_HAS_UNCONSUMED_REQUESTS(_r) \ - ({ \ - unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ - unsigned int rsp = RING_SIZE(_r) - \ - ((_r)->req_cons - (_r)->rsp_prod_pvt); \ - req < rsp ? req : rsp; \ - }) + ((((_r)->sring->req_prod - (_r)->req_cons) < \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \ + ((_r)->sring->req_prod - (_r)->req_cons) : \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) +#endif /* Direct access to individual ring elements, by index. */ #define RING_GET_REQUEST(_r, _idx) \